package com.czh.zhiwen.model.enums;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Slf4j
public enum ScoringStrategyEnum {
    AI("AI", 1),

    CUSTOM("自定义",0);

    private final String text;
    private final int value;

    ScoringStrategyEnum(String text, int value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 根据value获取枚举
     * @param value
     * @return
     */
    public static ScoringStrategyEnum getEnumByValue(int value) {
        if(ObjectUtils.isEmpty(value)){
            return null;
        }
        for (ScoringStrategyEnum strategyEnum : ScoringStrategyEnum.values()) {
            if (strategyEnum.value == value) {
                return strategyEnum;
            }
        }
        return null;
    }

    /**
     * 获取所有枚举值
     * @return
     */
    public static List<Integer> getAllEnum() {
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());

    }

    public String getText() {
        return text;
    }
    public int getValue() {
        return value;
    }
}
